<template>
	<view class="content">
		<view class="login-logo">
			<image class="login-logo-image" src="/static/logo.png" mode=""></image>
		</view>
		<view class="login-form">
			<view class="uni-form-item uni-column po">
				<input class="uni-input" v-model="moblie" type="number" placeholder-style="color:#cacaca" placeholder="请输入手机号" />
			</view>
			<view class="uni-form-item uni-column po">
				<input class="uni-input" v-model="password" password type="text" placeholder-style="color:#cacaca" placeholder="请输入密码" />
			</view>
			<view class="login-form-checkbox">
				<checkbox-group>
					<label>
						<checkbox value="cb" style="transform:scale(0.6)" color="#e83e41" checked="true" />注册/登陆即代表同意
					</label>
					<text class="login-form-link" @click="protocol">《爱八方古宝项目经销合作》</text>
				</checkbox-group>				
			</view>
			<view class="">
				<view class="login-form-btn" @click="post" :class="[disabled ? '' : 'disabled']">登录</view>				
			</view>
			<view class="login-form-tips">
				<text @click="codeLogin">手机快捷登录</text> | <text @click="reset">忘记密码</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
        mapState,
        mapMutations
    } from 'vuex'
	
	export default {
		data() {
			return {
				moblie: '',
				password: '',
				disabled:false
			}
		},
		onNavigationBarButtonTap(e) {
			uni.navigateTo({
				url: '/pages/login/register/register'
			});
		},
		onShow() {
			this.logout()
		},
		methods: {
			...mapMutations(['getNetworkType','vuexRequest','login','logout']),
			post() {
				if(!this.disabled){
					return !1
				}
				uni.showLoading({
					title: '登录中'
				});
				
				this.vuexRequest({
					url: '/api/v2/site/codee',
					method: 'POST',
					data: {usage:'register',mobile: '13018603104',group:'app'},
					success: (res)  => {
						uni.hideLoading()
					},
					fail: (err)  => {
						uni.hideLoading()
					},
				})
			},
			reset() {
				uni.navigateTo({
					url: '/pages/login/reset/reset'
				});
			},
			codeLogin() {
				uni.navigateTo({
					url: '/pages/login/code-login/code-login'
				});
			},
			protocol() {
				uni.navigateTo({
					url: '/pages/login/protocol/protocol'
				});
			}
		},
		watch: {
			moblie () {
				if(this.moblie != '' && this.password != ''){
					this.disabled = true
				}else{
					this.disabled = false
				}
			},
			password(){
				if(this.moblie != '' && this.password != ''){
					this.disabled = true
				}else{
					this.disabled = false
				}
			}
		}
	}
</script>

<style>
	page{
		background: #FFFFFF;
	}
	.po{
		position: relative;
	}
	.po:after{
		position: absolute;
		z-index: 10;
		right: 0;
		bottom: 0;
		left: 0;
		height: 1px;
		content: '';
		-webkit-transform: scaleY(.5);
		-ms-transform: scaleY(.5);
		transform: scaleY(.5);
		background-color: #c8c7cc;
	}
	.login-logo{
		text-align: center;
		padding: 60upx 0;
	}
	.login-logo-image{
		width: 153upx;
		height: 149upx;
		margin: 0 auto;
	}
	.login-form{
		width: 85%;
		margin: 0 auto;
	}
	.uni-input{
		padding-left: 0;
	}
	
	.login-form-checkbox {
		display: flex;
		padding:  20upx 0 0 0;
		font-size: 24upx;
		color: #cacaca;
		display: inline-flex;
	}
	uni-checkbox-group uni-label{
		padding: 0;
	}
	uni-radio-group, uni-checkbox-group{
		width: auto;
	}
	.login-form-link{
		color: #e83e41;
	}
	.login-form-btn{
		margin-top: 80upx;
		background: ;
		background-image: linear-gradient(to right, #f27072, #ea4a4c);
		text-align: center;
		border-radius: 200upx;
		height: 80upx;
		line-height: 80upx;
		font-size: 32upx;
		color: #FFFFFF;
	}
	.login-form-btn.disabled{
		background: #f09596;
	}
	.login-form-tips{
		padding-top: 40upx;
		text-align: center;
		color: #979797;
	}
</style>
